window.addEventListener('load', function () {
    let init = this.document.querySelector('.init')
    let logout = this.document.querySelector('.logout')
    let allA = this.document.querySelectorAll('.leftside > ul ul a ')
    init.addEventListener('click', function () {
        axios({
            method: 'get',
            url: '/init/data',
            // headers: { 'Authorization': localStorage.getItem('kshtoken') }
        }).then(res => {
            console.log(res);
            if (res.data.code == 0) {
                toastr.success(res.data.message)
            } else {
                toastr.warning(res.data.message)
            }
        })
    })

    //退出登录
    logout.addEventListener('click',function(){
        //清除token
        localStorage.removeItem('kshtoken')
        //跳转到登录页
        location.href='./login.html'
    })
    //导航栏高亮设置(菜单切换)-排他
    allA.forEach(ele=>{
        ele.addEventListener('click',function(){
        document.querySelector('.leftside > ul ul a.active').classList.remove('active')
        ele.classList.add('active')
    })
    })
})